
#include <iostream>
#include <vector>
#include <string>

class test {

    public:
        test() { std::cout << "in contrcutor" << std::endl;}
        ~test() { std::cout << "in ~desctructor" << std::endl;} 
};

void test_case1() {

    std::vector<test> vect;
    test t1;
    test t2;
    test t3;
    vect.push_back(std::move(t1));
    vect.push_back(std::move(t2));
    vect.push_back(std::move(t3));
    vect.clear(); 

    std::cout << "exit test case 1" << std::endl;
}

void test_case2() {

    std::vector<test*> vect;
    test* t1 = new test();
    test* t2 = new test();
    test* t3 = new test();
    vect.push_back(t1);
    vect.push_back(t2);
    vect.push_back(t3);
    vect.clear();
}


void test_case3() {

    std::vector<test*> vect;
    std::vector<test*> another_vector;
    test* t1 = new test();
    test* t2 = new test();
    test* t3 = new test();
    vect.push_back(t1);
    vect.push_back(t2);
    vect.push_back(t3);
    vect.clear();

    //the pointer will not be freed
    //std::vector<test *>().swap(vect);
    //vect.swap(std::vector<test*>());
}

void test_case4() {

    std::vector<test> vect;
    test t1;
    test t2;
    test t3;
    vect.push_back(std::move(t1));
    vect.push_back(std::move(t2));
    vect.push_back(std::move(t3));
    vect.clear(); 

    std::vector<test> another_vector;
    vect.swap(another_vector);

    std::cout << "exit test case 4" << std::endl;
}


void test_case5() {

    std::vector<char> vect = {'a', 'b', 'c', 'd', 'e', 'f', 'g'};

    for (auto i : vect) {
        std::cout << i ;
    }

    std::string my_str(&*vect.begin(), 3);
    std::cout << "\nmy_str: " << my_str;

    vect[0] = 'f';
    vect[1] = 'u';
    std::cout << "\nmy_str2: " << my_str << std::endl;
}

void test_case6() {
    std::vector<int> src = {0, 1, 2, 3, 4};
    std::vector<int> dst = {5,0};
    std::cout << "print src\n";
    for(auto i : src)
        std::cout << i << std::endl;
    std::cout << "print dst\n";
    for(auto i: dst) 
        std::cout << i << std::endl;

    std::copy(src.begin(), src.end(), dst.begin());

    std::cout << "after copy: print src\n";
    for(auto i : src)
        std::cout << i << std::endl;
    std::cout << "after copy: print dst\n";
    for(auto i: dst) 
        std::cout << i << std::endl;
}

int main() {

    //test_case1();
    //test_case2();
    //test_case3();
    //test_case4();
    //test_case5();
    test_case6();
    return 0;
}